<template>
  <div>
    <el-card class="box-card">
      <el-tabs v-model="activeName" >
        <el-tab-pane onclick="true" label="派单参数设置" name="first" >
          <el-form  :model="paidanform" >
            <el-button type="primary" @click="updatebycount" style="float:right"  v-if="countc%2==0">修改</el-button>
            <el-button type="primary" @click="updatebycount" style="float:right"  v-else-if="countc%2!=0">保存</el-button>
            <br>
            <el-divider></el-divider>
            <el-tag type="info">网约车半径</el-tag>
            <el-form-item label="初始半径">
              <el-input v-model="paidanform.reservationradius " placeholder="输入公里数" type="num" style="width: 15%" :readonly="readonly"></el-input><br><br>
              <el-tag type="info">拼车搜索半径</el-tag>初始半径:<el-input v-model="paidanform.carpoolingradius" placeholder="输入公里数" style="width: 15%" :readonly="readonly"></el-input>
            </el-form-item>
            <el-divider></el-divider>
            <el-tag type="info">每单推送次数</el-tag>
            <el-form-item label="最大推送次数">
              <el-input v-model="paidanform.pushtimes" placeholder="输入次数" style="width: 15%" :readonly="readonly"></el-input><span>(超过起步公里后，每公里单价)</span><br><br>
              <el-tag type="info">推送问题</el-tag>每次推送间隔: <el-input v-model="paidanform.looppushing" placeholder="输入金额" style="width: 15%" :readonly="readonly"></el-input><span>(元，支持两位小数，超过免费等待时间后，每分钟单价)</span><br><br>
              <el-tag type="info">循环推送</el-tag>重复推送:<el-input v-model="paidanform.pushinterval" placeholder="请输入分钟" style="width: 15%" :readonly="readonly"></el-input>
            </el-form-item>
            <el-divider></el-divider>
            <el-tag type="info">司机取消次数</el-tag>
            <el-form-item label="每天最多取消">
              <el-input v-model="paidanform.cancelorders" placeholder="请输入分钟" style="width: 15%" :readonly="readonly"></el-input><br><br>
              <el-tag type="info">路径偏离规划</el-tag> 偏离距离:<el-input v-model="paidanform.deviationdistance" placeholder="输入金额" style="width: 15%" :readonly="readonly"></el-input> <span>(元，支持两位小数，超时取消后产生的固定违约金)</span>
            </el-form-item>
          </el-form>
        </el-tab-pane>
        <el-tab-pane label="派单规则" name="second">
          <el-form  :model="chengkeform" >
            <span><font size="10px" color="red"><b>规则不允许手动修改，仅做文字说明</b></font></span>
            <br>
            <el-divider></el-divider>
            <el-tag type="info">全局最优派单</el-tag>
            <dl>
            <dd>1.时问最优(乘客订单发出后的等待时问最短)</dd>
            <dd>2.距离最优(接单后的等待可机时问最知)</dd>
          </dl>
            <el-divider></el-divider>
            <el-tag type="info">司机偏好</el-tag>
            <dl>
              <dd>1.订单金额</dd>
              <dd>2.订单里程</dd>
              <dd>3.接单距离</dd>
              <dd>4.订单类型(实时单/预约单)</dd>
              <dd>5.是否跨城</dd>
              <dd>6.是否回家顺路</dd>
            </dl>
            <el-divider></el-divider>
            <el-tag type="info">相同情况</el-tag>
            <dl>
              <dd>1.优先派给等待时同久的乘客</dd>
              <dd>2.优先合规、投诉少、评分更好的可机</dd>
              <dd>3.夜间女乘客派女司机</dd>
            </dl>

          </el-form>
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      paidanform:{
        reservationradius:'',
        carpoolingradius:'',
        pushtimes:'',
        pushinterval:'',
        looppushing:'',
        cancelorders:'',
        deviationdistance:'',
      },
      activeName: 'first',
      countc:0,
      readonly: true,
      paidan:[]
    };
  },
  mounted() {

  },
  created() {
    this.findAll()
  },
  methods: {
    findAll(){
      axios.get("http://localhost:8010/dev/findAll").then(res=>{
        this.paidan=res.data.data;
        this.paidanform=this.paidan[0]
      })
    },
    updatebycount() {
      this.countc+=1;
      console.log(this.countc)
      if (this.countc%2!=0){
        this.readonly = false;
      }else {
        this.readonly = true;
        axios.post('http://localhost:8010/pas/updatebyid',this.paidanform).then(res=>{
          if (res.data.code==1){
            this.$message({
              message: '修改成功',
              type: 'success'
            });
            this.findAll()
          }
        })
      }
      this.findAll()
    }
  },
};
</script>

<style scoped>
.pagination {
  text-align: right;
}
</style>
